# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# NOTE: This file is auto generated by the elixir code generator program.
# Do not edit this file manually.

defmodule GoogleApi.AccessContextManager.V1.Model.EgressTo do
  @moduledoc """
  Defines the conditions under which an EgressPolicy matches a request. Conditions are based on information about the ApiOperation intended to be performed on the `resources` specified. Note that if the destination of the request is also protected by a ServicePerimeter, then that ServicePerimeter must have an IngressPolicy which allows access in order for this request to succeed. The request must match `operations` AND `resources` fields in order to be allowed egress out of the perimeter.

  ## Attributes

  *   `externalResources` (*type:* `list(String.t)`, *default:* `nil`) - A list of external resources that are allowed to be accessed. Only AWS and Azure resources are supported. For Amazon S3, the supported formats are s3://BUCKET_NAME, s3a://BUCKET_NAME, and s3n://BUCKET_NAME. For Azure Storage, the supported format is azure://myaccount.blob.core.windows.net/CONTAINER_NAME. A request matches if it contains an external resource in this list (Example: s3://bucket/path). Currently '*' is not allowed.
  *   `operations` (*type:* `list(GoogleApi.AccessContextManager.V1.Model.ApiOperation.t)`, *default:* `nil`) - A list of ApiOperations allowed to be performed by the sources specified in the corresponding EgressFrom. A request matches if it uses an operation/service in this list.
  *   `resources` (*type:* `list(String.t)`, *default:* `nil`) - A list of resources, currently only projects in the form `projects/`, that are allowed to be accessed by sources defined in the corresponding EgressFrom. A request matches if it contains a resource in this list. If `*` is specified for `resources`, then this EgressTo rule will authorize access to all resources outside the perimeter.
  *   `roles` (*type:* `list(String.t)`, *default:* `nil`) - IAM roles that represent the set of operations that the sources specified in the corresponding EgressFrom. are allowed to perform in this ServicePerimeter.
  """

  use GoogleApi.Gax.ModelBase

  @type t :: %__MODULE__{
          :externalResources => list(String.t()) | nil,
          :operations => list(GoogleApi.AccessContextManager.V1.Model.ApiOperation.t()) | nil,
          :resources => list(String.t()) | nil,
          :roles => list(String.t()) | nil
        }

  field(:externalResources, type: :list)
  field(:operations, as: GoogleApi.AccessContextManager.V1.Model.ApiOperation, type: :list)
  field(:resources, type: :list)
  field(:roles, type: :list)
end

defimpl Poison.Decoder, for: GoogleApi.AccessContextManager.V1.Model.EgressTo do
  def decode(value, options) do
    GoogleApi.AccessContextManager.V1.Model.EgressTo.decode(value, options)
  end
end

defimpl Poison.Encoder, for: GoogleApi.AccessContextManager.V1.Model.EgressTo do
  def encode(value, options) do
    GoogleApi.Gax.ModelBase.encode(value, options)
  end
end
